 %% ѡ��ǰSelect_no��Ⱦɫ��
 function f=select(f1,number_2,number_1,n_1,Select_no)
 
%% f1Ҫѡ���Ⱦɫ�������
%% number_2 �ﵽ��Ⱦɫ�������,number_1 ���е�Ⱦɫ�������,n_1 Ⱦɫ�峤��-1,Select_no ѡ������
  number=number_2-number_1;
f1_ii1=f1(1:number,:);     %%����select_��ǰn�����Ⱦɫ��
f1_ii2=f1(number+1:number_2,:);  %%����ѡ���select_no-number��Ⱦɫ��
f1_ii_1=f1_ii1;
f1_ii_2=f1_ii2;
temp=max(f1(:,n_1+1));  
for i=1:temp
number_temp_1(i,:)=sum(f1_ii1(:,n_1+1)==i);
end

for i=1:temp
number_temp_2(i,:)=sum(f1_ii2(:,n_1+1)==i);
end
select=0;
  sel_loc=[];
i=1;

while select<Select_no-number&&i<=temp
[sel_c,sel_loc]=sort(number_temp_1) ;   %% ȡ��С������r,sel_c ��ֵ��sel_loc��λ�� �ڼ����ο���

loc=sel_loc(i,:);   %% �����Сֵ�ж��������1���������ѡ��һ����
f1_ii1_1=[];
z1=[];
z2=[];
if number_temp_2(loc,:)~=0
    [z1,z2]=find(f1_ii_2(:,n_1+1)==loc);  %%z1��λ��
    temp_1=unidrnd(size(z2,1));
    z1_temp=z1(temp_1,:);  
    f1_ii1_1=f1_ii_2(z1_temp,:);%%���ѡ��һ��Ⱦɫ��
    f1_ii_1=[f1_ii_1;f1_ii1_1];
    f1_ii_2=[f1_ii_2(1:z1_temp-1,:);f1_ii_2(z1_temp+1:size(f1_ii_2,1),:)];
    select=select+1;   %%ѡ���Ⱦɫ�������
    number_temp_1(loc,:)=number_temp_1(loc,:)+1;        %% r ������1
    number_temp_2(loc,:)=number_temp_2(loc,:)-1;
else
    select=select;
    i=i+1;
continue
end   

end
f=f1_ii_1;
 end